package edu.uoc.tdp.pac4.server.connexiomanteniment.exceptions;

import edu.uoc.tdp.pac4.connexiomanteniment.i18n.LanguageUtils;

public class ExceptionServer extends Exception {
	public static final String SQLERROR_VALUE_TOO_LONG = "ERROR: value too long";
	public static final String SQLERROR_NULL_VALUE = "ERROR: null value in column";
	public static final String SQLERROR_DUPLICATED_KEY = "ERROR: duplicate key value";
	public static final String SQLERROR_RELATION = "ERROR: relation";
	public static final String SQLERROR_COLUMN = "ERROR: column";
	public static final String SQLERROR_MISSING_VALUE = "No value specified";

	public static final String SERVER_DB_DRIVER_NOT_FOUND = "Server.DB.NoDriver";
	public static final String SERVER_DB_UNKNOWN_USER_ROLE = "Server.DB.UnknownUserRole";
	public static final String SERVER_DB_PROPERTY_FILE_NOT_FOUND = "Server.DB.PropertyFileNotFound";
	public static final String SERVER_DB_INCORRECT_PROPERTY_FILE = "Server.DB.IncorrectPropertyFile";
	public static final String SERVER_DB_CONNECTION_FAILED = "Server.DB.ConnectionFailed";
	public static final String SERVER_DB_UNEXPECTED_ERROR = "Server.DB.UnexpectedError";
	public static final String SERVER_DB_VALUE_TOO_LONG = "Server.DB.ValueTooLongForColumn"; 
	public static final String SERVER_DB_NULL_VALUE = "Server.DB.NullValue";
	public static final String SERVER_DB_CONSTRAINT = "Server.DB.UniqueConstraintViolated";
	public static final String SERVER_DB_CONSTRAINTEMAIL = "Server.DB.UniqueConstraintViolatedEmail";
	public static final String SERVER_DB_CONSTRAINTLOGIN = "Server.DB.UniqueConstraintViolatedLogin";	
	public static final String SERVER_DB_UNKNONW_TABLE = "Server.DB.TableDoesNotExist";
	public static final String SERVER_DB_UNKNOWN_COLUMN = "Server.DB.ColumnDoesNotExistOrWronglyInformed";
	public static final String SERVER_DB_MISSING_VALUE = "Server.DB.MissingValueInStatement";
	public static final String SERVER_DB_USER_NOT_EXIST = "Server.DB.UserDoesNotExist";
	public static final String SERVER_DB_USER_ALREADY_EXIST = "Server.DB.UserAlreadyExists";	
	
	public static final long serialVersionUID = 1L;
	private String codiError;
	private String additionalInfo;
	
	public ExceptionServer() {}
	public ExceptionServer(String pCodiError) { codiError = new String(pCodiError); }
	
	public void setErrorCode(String pCodiError) { codiError = pCodiError; }
	public String getErrorCode() { return codiError; }
	public String getLocalizedMessage() {
		LanguageUtils.setDefaultLanguage("i18n/messagesServer");
		return LanguageUtils.getMessage(codiError);
	}
	
	public void setAdditionalInfo(String pAdditionalInfo) { additionalInfo = pAdditionalInfo; }
	public String getAdditionalInfo() { return additionalInfo; }
}